function init() {
	_initHeader();
	
	var array = new Array();
	
	array.push("startAccelerometerSensor(once)");
	array.push("startAccelerometerSensor");
	array.push("stopAccelerometerSensor");
	array.push("startCompassSensor (once)");
	array.push("startCompassSensor");
	array.push("stopCompassSensor");
	array.push("turnOnLight");
	array.push("turnOffLight");
	array.push("vibrate");
	
	draw_list(array);
}

function setOnListClickHandler(idx) {
	switch(idx) {
		case 0 : // startAccelerometerSensor (once)
			sensor.startAccelerometerSensor(accelerometerSuccessCallback, accelerometerErrorCallback);
		break;
		
		case 1 : // startAccelerometerSensor
			sensor.startAccelerometerSensor(accelerometerSuccessCallback, accelerometerErrorCallback, 1000);
		break;
		
		case 2 : // stopAccelerometerSensor
			sensor.stopAccelerometerSensor();
		break;
		
		case 3 : // startCompassSensor (once)
			sensor.startCompassSensor(compassSuccessCallback, compassErrorCallback);
		break;
		
		case 4 : // startCompassSensor
			sensor.startCompassSensor(compassSuccessCallback, compassErrorCallback, 1000);
		break;
		
		case 5 : // stopCompassSensor
			sensor.stopCompassSensor();
		break;
		
		case 6 : // turnOnLight
			sensor.turnOnLight();
		break;
		
		case 7 : // turnOffLight
			sensor.turnOffLight();
		break;
		
		case 8 : // vibrate
			sensor.vibrate();
		break;
		
		default :
		break;
	}
}

function accelerometerSuccessCallback(acceleration) {
	log.log("Sensor: accelerometer" + acceleration.x + acceleration.y, acceleration.z);
	
	var accelerationInfo = "x:" + acceleration.x + "\n" + "y:" + acceleration.y + "\n" + "z:" + acceleration.z;
	$("#acceleration").text(accelerationInfo);
}

function accelerometerErrorCallback() {
	alert("accelerometer ErrorCallback");
}

function compassSuccessCallback(heading) {
	log.log("Sensor: compass " + heading.trueHeading + heading.magneticHeading, heading.headingAccuracy);
	
	var compassInfo = "trueHeading:" + heading.trueHeading + "\n" + "magneticHeading:" + heading.magneticHeading + "\n" + "headingAccuracy:" + heading.headingAccuracy;
	$("#heading").text(compassInfo);
}

function compassErrorCallback() {
	alert("compass ErrorCallback");
}